package fun.chutianshu;

public abstract class Pet {
    private int age;
    private String name;
    private int hp;
    private String color;
    private int ap;

    public int getInitHp() {
        return initHp;
    }

    public void setInitHp(int initHp) {
        this.initHp = initHp;
    }

    //初始生命值
    private int initHp;

    public String getColor() {
        return color;
    }

    @Override
    public String toString() {
        return "Pet{" +
                "age=" + age +
                ", name='" + name + '\'' +
                ", hp=" + hp +
                ", color='" + color + '\'' +
                ", ap=" + ap +
                '}';
    }

    public abstract void printPet();

    public void attack(Pet enemy){
        if(enemy.getHp()>=0)
        {
            enemy.setHp(enemy.getHp()-this.ap);
            System.out.println(this.name+" 攻击 " + enemy.getName()+"： ");
            System.out.println(enemy.getName()+" 掉了 "+ this.ap +"点血, 当前血量："+enemy.getHp());

            if(enemy instanceof Phenix)
            {
                ((Phenix) enemy).reborn();
            }
        }
        else {
            System.out.println("请不要鞭尸！！！");
        }
    };

    public abstract void play();

    public void setColor(String color) {
        this.color = color;
    }

    public int getAp() {
        return ap;
    }

    public void setAp(int ap) {
        this.ap = ap;
    }

    public Pet(int age, String name, int hp, String color, int ap) {
        this.age = age;
        this.name = name;
        this.hp = hp;
        this.color = color;
        this.ap = ap;
        this.initHp = hp;
    }

    public Pet(){};

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getHp() {
        return hp;
    }

    public void setHp(int hp) {
        this.hp = hp;
    }

    // 吃
    public void eat(Food food){
        System.out.println(this.name+"在吃东西.....");
        System.out.println(this.name+"一口吞下"+food.getName());
        if(this.hp+food.getAddHpNum()>this.initHp){
            this.hp=this.initHp;
        }
        else {
            this.hp+=food.getAddHpNum();
        }
        System.out.println(this.name+"当前生命为："+this.hp);
    }
}
